package com.nulldev.util.scripting.cup.vee.utils;

import com.nulldev.util.scripting.cup.vee.CUPRegister.CUPRegisterType;

public interface VEEConstants {
	public static final boolean USE_SIL_REV_1 = true;

	public static boolean isWithinBounds(final CUPRegisterType type, final Object item) {
		switch (type) {
			case SHORT:
				return (item instanceof Integer || item instanceof Short) && ((int) item) <= Short.MAX_VALUE && ((int) item) >= Short.MIN_VALUE;
			case NORMAL:
				return (item instanceof Integer || item instanceof Short) && ((int) item) <= Integer.MAX_VALUE && ((int) item) >= Integer.MIN_VALUE;
			case WIDE:
				return (item instanceof Long || item instanceof Integer || item instanceof Short) && ((long) item) <= Long.MAX_VALUE
						&& ((long) item) >= Long.MIN_VALUE;
			case FLOAT:
			case FLOAT_SFP:
				return (item instanceof Float) && ((float) item) <= Float.MAX_VALUE && ((float) item) >= Float.MIN_VALUE;
			case DOUBLE:
				return (item instanceof Double) && ((double) item) <= Double.MAX_VALUE && ((double) item) >= Double.MIN_VALUE;
			case CUSTOM:
			default:
				return false;
		}
	}
}
